
\documentclass{article}

%\usepackage[top=25mm,bottom=25mm,left=25mm,right=25mm]{geometry}
\usepackage{graphicx}
%\usepackage{amsmath}
%\usepackage{subfig}
%\usepackage{epstopdf}

\begin{document}

\title{ESP - Digital lab 3}
\author{Floris van Nee \& Simon Dirlik}

\maketitle

\section{} %1
The plotted function can be found in figure \ref{fig:31}. The code that was used to plot is as follows:

\begin{verbatim}
FS=20000;
f1=2500;
L=256;
Ts=1/FS;
OM=2*pi*f1*Ts;
n=1:L;
xn=sin(n.*OM);
figure(1);
stem(n,xn);
\end{verbatim}

\begin{figure}
	\centering
		\includegraphics[width=1.00\textwidth]{31.eps}
	\caption{Answer to problem 3.1. The function x(n) plotted with stem}
	\label{fig:31}
\end{figure}

\section{} %2
The frequency response plot can be found in figure \ref{fig:32}.

\begin{verbatim}
load spectrum;
semilogy(f,fresponse);
\end{verbatim}

\begin{figure}
	\centering
		\includegraphics[width=1.00\textwidth]{32.eps}
	\caption{Answer to problem 3.2. The plotted Fourier transform x(n)}
	\label{fig:32}
\end{figure}

\section{} %3
The output of fftflops can be found in figure \ref{fig:33}. It can be seen that the minima occur when $N$ is a power of 2. Maxima occur when $N$ is a prime number. Apparently, the number of calculations is related to the decomposition of a number into prime factors, or specifically multiples of two.

Theoretically, the complexity of the FFT with powers of 2 is $N log N$. The number of flops shown in this figure is far higher for powers of 2 than the theoretical number of flops needed for powers of 2.

\begin{figure}
	\centering
		\includegraphics[width=1.00\textwidth]{33.eps}
	\caption{Answer to problem 3.3. The output of fftflops}
	\label{fig:33}
\end{figure}

\section{} %4
The amplitude spectrum can be found in figure \ref{fig:34}. There are two peaks, one at the actual frequency 2500 Hz and one because of folding at 17500 Hz. There is also a noise floor, which is caused by the fft, because it only has a limited amount of points.

\begin{figure}
	\centering
		\includegraphics[width=1.00\textwidth]{34.eps}
	\caption{Answer to problem 3.4. Amplitude spectrum of x(n)}
	\label{fig:34}
\end{figure}

\section{} %5
The amplitude spectrum can be found in figure \ref{fig:35}. The difference is that the noise floor is much higher. This happens, because the sampling frequency is not an exact multiple of the signal frequency anymore.

\begin{figure}
	\centering
		\includegraphics[width=1.00\textwidth]{35.eps}
	\caption{Answer to problem 3.5. Amplitude spectrum of x(n) for 2501 Hz}
	\label{fig:35}
\end{figure}

\section{} %6
The plots can be found in figure \ref{fig:36}. The left one is similar to previous results, because the number of fft points is equal to the number of samples. In the right plot, there is a difference. This is, because the number of samples is less than the number of points. Matlab extends the number of samples with zeros until it is of the same length as the number of fft points.

\begin{figure}
	\centering
		\includegraphics[width=1.00\textwidth]{36.eps}
	\caption{Answer to problem 3.6. The left plot shows the result for a fft with 200 points, the right one with 256 points.}
	\label{fig:36}
\end{figure}

\section{} %7
The plots can be found in figure \ref{fig:371} and \ref{fig:372}.

\begin{figure}
	\centering
		\includegraphics[width=1.00\textwidth]{371.eps}
	\caption{Answer to problem 3.7.1.}
	\label{fig:371}
\end{figure}

\begin{figure}
	\centering
		\includegraphics[width=1.00\textwidth]{372.eps}
	\caption{Answer to problem 3.7.2.}
	\label{fig:372}
\end{figure}

\section{} %8
Several window functions were applied to the signal to obtain the two frequencies. The figure that shows this is figure \ref{fig:38}. It can be seen that a kaiser window with beta=9 gives us the desired result. There are two frequencies, one at approximately 4000 Hz and one at approximately 840 Hz. The amplitude of the large signal is normalized to 1, then the amplitude of the small signal is approximately $7 \cdot 10^{-6}$.

\begin{figure}
	\centering
		\includegraphics[width=1.00\textwidth]{38.eps}
	\caption{Answer to problem 3.8. The fft signal with different window functions.}
	\label{fig:38}
\end{figure}


\end{document}
